public class HashBuck {
    static class Node{
        public int key;
        public int val;
        public Node next;

        public Node(int key, int val) {
            this.key = key;
            this.val = val;
        }
    }

    public Node[] array = new Node[10];
    public int useSize;
    public static final double LOAD_FACTOR = 0.75;

    public void push(int key,int val){
        Node node = new Node(key, val);
//        1.找位置
        int index = key % array.length;
//        2.遍历数组
        Node cur = array[index];
        if (cur == null){
//            头插法
            array[index] = node;
            return;
        }
        while(cur!=null){
            if (cur.val == key){
//                更新val
                cur.val = val;
            }
            cur = cur.next;
        }
//        头插法
//        node.next = cur;
//        cur = node;
        node.next = array[index];
        array[index] = node;
        useSize++;
        if (doLoadFactor() >= 0.75){
//            重新哈希
            reSize();
        }
    }

    private void reSize() {

    }

    //    计算负载因子
    private double doLoadFactor(){
        return useSize*1.0 / array.length;
    }
}
